# -*- encoding: utf-8 -*-
"""
File Name: init
Description:
Author : 'lirui'
date: 2024/7/15
Contact: marjey_lee@163.com
Change Activity:
2024/7/15:
"""
import time

from DrissionPage._configs.chromium_options import ChromiumOptions
from DrissionPage._pages.chromium_page import ChromiumPage

from ll.modules.controller.utils.web_util import WebUtil


def load_init_page(
        url,
        path=r'C:\Program Files\Google\Chrome\Application/Google Chrome'
):
    """

    Args:
        url:
        path:

    Returns:

    """
    try:
        co = ChromiumOptions().set_browser_path(path)
        page = ChromiumPage(co)
        page.get(url)
        page.refresh()
        ele = page.ele('#details-button')
        if not WebUtil.check_is_element_exist(ele):
            return page
        ele.click()
        time.sleep(1)
        page.ele('#proceed-link').click()
        return page
    except Exception as e:
        print(e)
